{include file="common/header"}

<!-- 编辑器 -->
<script charset="utf-8" src="/Public/library/kindeditor/kindeditor-all-min.js"></script>
<script charset="utf-8" src="/Public/library/kindeditor/lang/zh-CN.js"></script>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
       
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                   <div class="ibox-title">
                            <h5>编辑角色</h5>
                            <span class="label label-primary pull-right label-primary-cust">
                            <a href="javascript:history.back(-1);" class="fa-lg-cust-a" title="返回上一页">
                                <i class="fa fa-arrow-left fa-lg-cust" aria-hidden="true"></i>
                            </a>
                        </span> 
                    </div>
                    <div class="ibox-content">
                        <div class="alert alert-danger">
                            <b>警告：</b>编辑角色组时，勾选哪个功能，该角色组则拥有哪些功能权限，请谨慎操作
                        </div>
                        <form class="form-horizontal m-t" id="partner" enctype="multipart/form-data">
                            <input type="hidden" name="auth_group_id" value="<?php echo $group_res['auth_group_id']; ?>">
                            <div class="form-group">
                                <label class="col-sm-3 control-label">角色名称：</label>
                                <div class="col-sm-8">
                                    <input name="group_name" value="<?php echo $group_res['group_name']; ?>" type="text" class="form-control" required="" aria-required="true">
                                </div>
                            </div>



                            <div class="form-group">
                            <label class="col-sm-3 control-label">菜单管理：</label>
                                 <div class="col-sm-8">
                                     <div class="alert alert-info" role="alert">
                                         <?php foreach ($menus as $key => $value): ?>
                                         <?php if(in_array($value['menu_id'],explode(',',$group_res['menus']))){
                                                 $is_check = 'checked="checked"';
                                             }else{
                                                 $is_check = '';
                                             }; ?>
                                         <label><input type="checkbox" name="menus[]" <?php echo $value['menu_id']==1?'onclick="return false" checked="checked"':''; ?> <?php echo $is_check; ?> value="<?php echo $value['menu_id']; ?>"><?php echo $value['menu_name']; ?></label>
                                         &nbsp;&nbsp;
                                         <?php endforeach ?>
                                     </div>
                                 </div>

                                <!--<label class="col-sm-3 control-label">菜单管理：</label>
                                 <div class="col-sm-8">
                                     <div class="checkout_menu">
                                         <?php foreach ($menus as $key => $value): ?>
                                         <?php if(in_array($value['menu_id'],explode(',',$group_res['menus']))){
                                                 $is_check = 'checked="checked"';
                                             }else{
                                                 $is_check = '';
                                             }; ?>
                                         <label><input type="checkbox" name="menus[]" <?php echo $value['menu_id']==1?'onclick="return false" checked="checked"':''; ?> <?php echo $is_check; ?> value="<?php echo $value['menu_id']; ?>"><?php echo $value['menu_name']; ?></label>
                                         &nbsp;&nbsp;
                                         <?php endforeach ?>
                                     </div>
                                 </div>-->
                                <!-- <div class="col-sm-8">
                                     <?php foreach ($menus as $key => $value): ?>
                                     <?php if(in_array($value['menu_id'],explode(',',$group_res['menus']))){
                                                 $is_check = 'checked="checked"';
                                             }else{
                                                 $is_check = '';
                                             }; ?>
                                     <label><input type="checkbox" name="menus[]" <?php echo $value['menu_id']==1?'onclick="return false" checked="checked"':''; ?> <?php echo $is_check; ?> value="<?php echo $value['menu_id']; ?>"><?php echo $value['menu_name']; ?></label>
                                     &nbsp;&nbsp;
                                     <?php endforeach ?>
                                 </div>-->
                        </div>
                            <div class="form-group form-group-bottom">
                                <div class="col-sm-2 col-sm-offset-3">
                                    <p class="btn btn-primary" onclick="submitAdd();">确定修改</p>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            
            </div>
           
        </div>
    </div>
</body>
{include file="common/footer"}
<script>
    //按钮样式
    $(document).ready(function(){$(".i-checks").iCheck({checkboxClass:"icheckbox_square-green",radioClass:"iradio_square-green",})});

    //添加会员
    function submitAdd(){
        $.ajax({
            url: "/Admin/Auth/group_edit",
            data:$('#partner').serialize(),
            type: "POST",
            dataType:'json',
            success: function (d) {
                if(d){
                    if(d.error){
                        swal(d.msg, "", "warning");
                        return false;
                }else{
                        swal(d.msg, "", "success");
                        setTimeout("window.location.href='/admin/Auth/group_list'",1000);
                        //setTimeout("window.location.reload()",1000);
                    }
                }
            }
        })

    }
</script>
